package ano.it.service.impl;

import ano.it.dao.GreenHouseDao;
import ano.it.pojo.DetailedData;
import ano.it.pojo.GreenHouse;
import ano.it.service.ReportService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = ReportService.class)
@Transactional
public class ReportServiceImpl implements ReportService {
    @Autowired
    private GreenHouseDao greenHouseDao;
    @Override
    public List<DetailedData> getBusinessReportData() {
        List<DetailedData> list=greenHouseDao.getBusinessReportData();
        for (DetailedData detailedData : list) {
            GreenHouse greenHouse=greenHouseDao.getGreenHouseData(detailedData.getId());
            System.out.println(detailedData);

            if(greenHouse!=null){
                detailedData.setName(greenHouse.getName());
                detailedData.setCrop(greenHouse.getCrop());
                detailedData.setUndertaker(greenHouse.getUndertaker());
                detailedData.setDevicenum(greenHouse.getDevicenum());
            }
        }

        return list;
    }
}
